<?php
// $Id: node.tpl.php,v 1.24 2010/12/01 00:18:15 webchick Exp $
//ffmpeg -i video1.avi -vcodec libx264 -threads 0 -r 25 -g 50 -b 500k -bt 500k -acodec libfaac -ar 44100 -ab 64k video1.mp4
//ffmpeg -i video1.avi -ac 1 -ar 22050 -ab 32k -f flv -b 700k -s 640x360 -y video1.flv
//ffmpeg -i video1.avi -vcodec libx264 -threads 0 -r 25 -g 50 -b 500k -bt 500k -s 640x360 -acodec libmp3lame -ar 44100 -ab 64k video1.mp4
//ffmpeg -i video1.avi -vcodec libx264 -threads 0 -b 500k -bt 500k -s 640x360 -acodec libmp3lame -ar 44100 -ab 64k video1.mp4
//ffmpeg -i video1.avi -vcodec libx264 -g 50 -b 800k -bt 800k -vpre E:\wrk\ffmpeg\presets\libx264-main.ffpreset -acodec libmp3lame -ac 2 -ar 44100 -ab 128k video1.mp4
?>
<?php 
if (!$page) { 
$rate = rate_get_results('node', $node->nid, 1);
?>
<a href="<?php print $node_url; ?>" class="thumb"><?php if (isset($user->data['govideo_addto'][$node->nid])) {print '<span class="add">&nbsp;</span>';} ?><?php if ($rate['rating']) {print '<span class="rated">&nbsp;</span>';} ?><?php print render($content['field_video']); ?></a>
<div class="bigsec">
  <h4><a href="<?php print $node_url; ?>" class="colr"><?php print truncate_utf8($title, 70, FALSE, TRUE); ?></a></h4>
  <div class="clear"></div>
  <div class="yourhere"><?php print render($content['field_videocategory']); ?></div>
  <div class="clear"></div>
  <?php hide($content['rate_fivestar']); hide($content['comments']); hide($content['links']); $ou = render($content); print ($ou ? $ou : '<p>&nbsp;</p>');?>
  <div class="clear"></div>
  <div class="postedby">
    <p class="postbytxt"><?php print t('By').': '.$name; ?></p>
    <?php if (module_exists('statistics') and $statistics = statistics_get($node->nid)) { ?><p class="views"><span class="left"><?php print t('Views').': '; ?></span>&nbsp;<?php print $statistics['totalcount']; ?></p><?php } ?>
  </div>
  <div class="right">
  <?php /* ?><p class="time">1:50</p><?php */ ?>
  <p class="date"><span><?php print t('!time ago',array('!time' => format_interval(time() - $node->created,1))); ?></span></p>
  <div class="rating">
    <?php print render($content['rate_fivestar']); ?>
  </div>
  </div>
</div>
<div class="smallsec">
  <h6><a href="<?php print $node_url; ?>" class="colr"><?php print truncate_utf8($title, 30, FALSE, TRUE); ?></a></h6>
  <div class="clear"></div>
  <?php /* ?><p class="time">1:50</p><?php */ ?>
  <p class="date"><?php print t('!time ago',array('!time' => format_interval(time() - $node->created,1))); ?></p>
  <div class="clear"></div>
  <div class="rating">
    <?php print render($content['rate_fivestar']); ?>
    <?php if (isset($statistics)) { ?><p class="views"><?php print format_plural($statistics['totalcount'], '1 view', '@count views'); ?></p><?php } ?>
  </div>
  <div class="clear"></div>
</div>
<?php } else { ?>
<?php //print '<pre>'. check_plain(print_r($content['field_video'], 1)) .'</pre>'; ?>
<?php 
  //drupal_add_js('misc/collapse.js'); 
  global $base_url, $user;
  
  //original
  //govideo_set_background($node->field_background_video[$node->language][0]['uri']);
  //Gassa changed
  govideo_set_background($node->field_background_video['und'][0]['uri']);
  if (!$user->uid) {
    $var['node'] = $node; 
    $us = govideo_helper_forbidden($var);
  } else {
    $us = '';
  }
  $destination = array('destination' => "node/$node->nid");
?>
<!-- Video Detail -->
<div class="videodetail">
  <!-- Short Detail -->
  <div class="shortdetail">
    <div class="videoby">
      <?php print $user_picture.'<p>'.t('By').'</p>'.$name; ?>
    </div>
    <div class="videodate"><?php print $date; ?></div>
    <div class="subscribe">
    <?php 
    if ($us) {
      $su = t('Subscribe');
      $sa = ' class="subscribe-btn"';
    } elseif (isset($user->data['govideo_subscribe'][$node->uid])){
      $su = t('Subscribed'); 
      $sa = ' class="subscribe-btn un"';
    } else {
      $su = t('Subscribe'); 
      $sa = '';
    }?>
    <a href="<?php print url('subscribe/'.$node->nid, array('query' => $destination)); ?>"<?php print $sa; ?>"><?php print $su; ?></a>
    </div>
    <?php if (module_exists('statistics') and $statistics = statistics_get($node->nid)) { ?>
    <div class="videoviews"><p><?php print format_plural($statistics['totalcount'], '1 view', '@count views'); ?></p></div>
    <?php } ?>
  </div>
  <div class="clear"></div>
  
  <div class="tabcont" id="subscribetab">
      <?php if ($us) { 
        print $us; 
      } else { 
        if (isset($user->data['govideo_subscribe'][$node->uid])) { 
          print '<p>'.t('You are now subscribed to !name.', array('!name' => $name)).'</p>';
          print '<div class="subscribe"><a href="'.url('subscribe/'.$node->nid, array('query' => $destination)).'" class="un">'.t('Unsubscribe').'</a></div>';
        } else {
          print '<a href="'.url('subscribe/'.$node->nid, array('query' => $destination)).'">'.t('Subscribe').'</a>';
        }
      } ?>
    <div class="clear"></div>
  </div>
  
  <!-- Big Video -->
  <div class="videobig">
    <?php print render($content['field_video']); ?>
  </div>

  <div class="clear"></div>
  <!-- Video tabs -->
  <div class="videotabs">
    <div class="tabbuttons">
      <?php print render($content['rate_fivestar']); ?>
      <ul id="descr" class="tablinks"><li><a href="#" class="descr-btn"><span class="descrbtn"><?php print t('Description'); ?></span></a></li></ul>
      <ul id="share" class="tablinks"><li><a href="#" class="share-btn"><span class="sharebtn"><?php print t('Share'); ?></span></a></li></ul>
      <ul id="embed" class="tablinks"><li><a href="#" class="embed-btn"><span class="embed"><?php print t('Embed'); ?></span></a></li></ul>
      <ul id="addto" class="tablinks"><li><?php if ($us) { ?><a href="#" class="addto-btn"><span class="addto"><?php print t('Add to Favorites'); ?></span><?php /*<span class="downarrow">&nbsp;</span> */?></a><?php } else { if (isset($user->data['govideo_addto'][$node->nid])) { ?><a href="<?php print url('addto/'.$node->nid, array('query' => $destination)); ?>" class="addto-btn"><span class="addto un"><?php print t('Added to Favorites'); ?></span></a><?php } else { ?><a href="<?php print url('addto/'.$node->nid, array('query' => $destination)); ?>"><span class="addto"><?php print t('Add to Favorites'); ?></span></a><?php }} ?>
      </li></ul>
      <ul id="flag" class="tablinks"><li><a href="#" class="flag-btn"><span class="flag"></span></a></li></ul>
    </div>
    <div class="clear"></div>

     <div class="tabcont videotext" id="descrtab">
      <?php hide($content['comments']); hide($content['links']); hide($content['my_additional_field']); print render($content);?>
    </div>

    <div class="tabcont" id="sharetab">
      <input type="text" value="<?php print url('node/'.$node->nid, array('absolute' => TRUE)); ?>" name="s" class="chain" />
      <div class="clear"></div>
      <div class="shareicons"><?php print render($content['my_additional_field']); ?></div>
    </div>

    <div class="tabcont" id="embedtab">
      <h4 class="embed-title">560x349</h4>
      <div class="embed-text"><?php print check_plain('<iframe width="560" height="349" src="'.$base_url.'/embed/'.$node->nid.'/560x349" frameborder="0" allowfullscreen></iframe>'); ?></div>
      <div class="clear">&nbsp;</div>
      <h4 class="embed-title">640x390</h4>
      <div class="embed-text"><?php print check_plain('<iframe width="640" height="390" src="'.$base_url.'/embed/'.$node->nid.'/640x390" frameborder="0" allowfullscreen></iframe>'); ?></div>
      <div class="clear">&nbsp;</div>
      <h4 class="embed-title">853x510</h4>
      <div class="embed-text"><?php print check_plain('<iframe width="853" height="510" src="'.$base_url.'/embed/'.$node->nid.'/853x510" frameborder="0" allowfullscreen></iframe>'); ?></div>
      <div class="clear">&nbsp;</div>
      <h4 class="embed-title">1280x750</h4>
      <div class="embed-text"><?php print check_plain('<iframe width="1280" height="750" src="'.$base_url.'/embed/'.$node->nid.'/1280x750" frameborder="0" allowfullscreen></iframe>'); ?></div>
      <div class="clear"></div>
    </div>
    
    <div class="tabcont" id="addtotab">
       <?php if ($us) { 
        print $us; 
      } else { 
        if (isset($user->data['govideo_subscribe'][$node->uid])) { 
          print '<p>'.t('"!name" added to Favorites.', array('!name' => $title)).'</p>';
          print '<div class="subscribe"><a href="'.url('addto/'.$node->nid, array('query' => $destination)).'" class="un">'.t('Remove from Favorites').'</a></div>';
        } else {
          print '<a href="'.url('subscribe/'.$node->nid, array('query' => $destination)).'">'.t('Add to Favorites').'</a>';
        }
      } ?>
      <div class="clear"></div>
    </div>

    <div class="tabcont" id="flagtab">
       <?php if ($us) { 
        print $us; 
      } else { 
        print variable_get('user_mail_register_video_flag_text', t("<h4>Report This Video as Inappropriate</h4>Please select the category that most closely reflects your concern about the video, so that we can review it and determine if it violates our Community Guidelines or isn't appropriate for all viewers. Abusing this feature is also a violation of the Community Guidelines, so don't do it.")).render(drupal_get_form('govideo_helper_flag_form'));
      } ?>
      <div class="clear"></div>
    </div>

  </div>
</div>
<div class="clear"></div>
<div class="videotext">
  <?php //hide($content['comments']); hide($content['links']); print render($content);?>
  <div class="clear"></div>
</div>
<?php print govideo_set_suggestions(); ?>
<?php print render($content['comments']); ?>
<?php } ?>
<?php //print '<pre>'. check_plain(print_r($content['field_video'], 1)) .'</pre>'; ?>